<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>C MIP-SDK: ring_buffer.h Source File</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />

<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>

</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">C MIP-SDK
   
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
      <li>
        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
      </li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
      <li><a href="globals.html"><span>Globals</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">ring_buffer.h</div>  </div>
</div>
<div class="contents">
<a href="ring__buffer_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 
<a name="l00002"></a>00002 <span class="comment">//</span>
<a name="l00006"></a>00006 <span class="comment"></span><span class="comment">//</span>
<a name="l00008"></a>00008 <span class="comment"></span><span class="comment">//</span>
<a name="l00009"></a>00009 <span class="comment">// External dependencies:</span>
<a name="l00010"></a>00010 <span class="comment">//</span>
<a name="l00011"></a>00011 <span class="comment">//  </span>
<a name="l00012"></a>00012 <span class="comment">// </span>
<a name="l00014"></a>00014 <span class="comment"></span><span class="comment">//</span>
<a name="l00017"></a>00017 <span class="comment"></span><span class="comment">//</span>
<a name="l00027"></a>00027 <span class="comment"></span><span class="comment">//</span>
<a name="l00029"></a>00029 <span class="comment"></span>
<a name="l00030"></a>00030 <span class="preprocessor">#ifndef _RING_BUFFER_H</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span><span class="preprocessor">#define _RING_BUFFER_H</span>
<a name="l00032"></a>00032 <span class="preprocessor"></span>   
<a name="l00034"></a>00034 <span class="comment">//</span>
<a name="l00035"></a>00035 <span class="comment">//Include Files</span>
<a name="l00036"></a>00036 <span class="comment">//</span>
<a name="l00038"></a>00038 <span class="comment"></span>
<a name="l00039"></a>00039 <span class="preprocessor">#include &quot;<a class="code" href="mip__types_8h.html">mip_types.h</a>&quot;</span>
<a name="l00040"></a>00040 <span class="preprocessor">#include &lt;string.h&gt;</span>
<a name="l00041"></a>00041 <span class="preprocessor">#include &lt;stdlib.h&gt;</span>
<a name="l00042"></a>00042 
<a name="l00043"></a>00043 
<a name="l00044"></a>00044 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00045"></a>00045 <span class="preprocessor"></span> <span class="keyword">extern</span> <span class="stringliteral">&quot;C&quot;</span> {
<a name="l00046"></a>00046 <span class="preprocessor">#endif</span>
<a name="l00047"></a>00047 <span class="preprocessor"></span>
<a name="l00049"></a>00049 <span class="comment">//</span>
<a name="l00050"></a>00050 <span class="comment">// Defines</span>
<a name="l00051"></a>00051 <span class="comment">//</span>
<a name="l00054"></a>00054 <span class="comment"></span>
<a name="l00055"></a>00055 <span class="preprocessor">#define RING_BUFFER_UNINITIALIZED 0</span>
<a name="l00056"></a>00056 <span class="preprocessor"></span><span class="preprocessor">#define RING_BUFFER_INITIALIZED   1</span>
<a name="l00057"></a>00057 <span class="preprocessor"></span>
<a name="l00058"></a>00058 <span class="preprocessor">#define RING_BUFFER_OK            0</span>
<a name="l00059"></a>00059 <span class="preprocessor"></span><span class="preprocessor">#define RING_BUFFER_ERROR         1</span>
<a name="l00060"></a>00060 <span class="preprocessor"></span><span class="preprocessor">#define RING_BUFFER_MEMORY_ERROR  2</span>
<a name="l00061"></a>00061 <span class="preprocessor"></span><span class="preprocessor">#define RING_BUFFER_SIZE_MISMATCH 3</span>
<a name="l00062"></a>00062 <span class="preprocessor"></span><span class="preprocessor">#define RING_BUFFER_EMPTY         4</span>
<a name="l00063"></a>00063 <span class="preprocessor"></span><span class="preprocessor">#define RING_BUFFER_FULL          5</span>
<a name="l00064"></a>00064 <span class="preprocessor"></span>
<a name="l00065"></a>00065 <span class="preprocessor">#define RING_BUFFER_STATIC_TYPE 0</span>
<a name="l00066"></a>00066 <span class="preprocessor"></span><span class="preprocessor">#define RING_BUFFER_MALLOC_TYPE 1</span>
<a name="l00067"></a>00067 <span class="preprocessor"></span>
<a name="l00069"></a>00069 <span class="comment">//</span>
<a name="l00070"></a>00070 <span class="comment">// Structures</span>
<a name="l00071"></a>00071 <span class="comment">//</span>
<a name="l00073"></a>00073 <span class="comment"></span>
<a name="l00074"></a><a class="code" href="struct__ring__buffer.html">00074</a> <span class="keyword">typedef</span> <span class="keyword">struct </span><a class="code" href="struct__ring__buffer.html">_ring_buffer</a>
<a name="l00075"></a>00075 {
<a name="l00076"></a>00076  <span class="comment">//State</span>
<a name="l00077"></a>00077  u8 state; 
<a name="l00078"></a>00078  u8 type;
<a name="l00079"></a>00079   
<a name="l00080"></a>00080  <span class="comment">//Ring buffer variables</span>
<a name="l00081"></a>00081  u8 *entries;
<a name="l00082"></a>00082  u32 max_entries;
<a name="l00083"></a>00083  u32 entry_size;
<a name="l00084"></a>00084  
<a name="l00085"></a>00085  u32 <span class="keyword">volatile</span> position;
<a name="l00086"></a>00086  u32 <span class="keyword">volatile</span> current_count;
<a name="l00087"></a>00087  
<a name="l00088"></a>00088  <span class="comment">//Stats</span>
<a name="l00089"></a>00089  u32 <span class="keyword">volatile</span> total_entries_written;
<a name="l00090"></a>00090  u32 <span class="keyword">volatile</span> total_entries_read;
<a name="l00091"></a>00091  u32 <span class="keyword">volatile</span> total_overruns; 
<a name="l00092"></a>00092 }<a class="code" href="struct__ring__buffer.html">ring_buffer</a>;
<a name="l00093"></a>00093 
<a name="l00094"></a>00094 
<a name="l00096"></a>00096 <span class="comment">//</span>
<a name="l00097"></a>00097 <span class="comment">// Function Prototypes</span>
<a name="l00098"></a>00098 <span class="comment">//</span>
<a name="l00100"></a>00100 <span class="comment"></span>
<a name="l00101"></a>00101 
<a name="l00102"></a>00102 <span class="comment">//External</span>
<a name="l00103"></a>00103 
<a name="l00104"></a>00104 u16 <a class="code" href="ring__buffer_8h.html#a00e0e84737691f9956f36080ccfa2df5">ring_buffer_init_static</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u8 *data_buffer_ptr, u32 max_entries, u32 entry_size);
<a name="l00105"></a>00105 u16 <a class="code" href="ring__buffer_8h.html#aaaa7983a42259ec3493bdc6da95e3271">ring_buffer_init_malloc</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u32 max_entries, u32 entry_size);
<a name="l00106"></a>00106 
<a name="l00107"></a>00107 u32 <a class="code" href="ring__buffer_8h.html#a62de05750671678f480ef82d2bffd0c6">ring_buffer_count</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer);
<a name="l00108"></a>00108 u32 <a class="code" href="ring__buffer_8h.html#a164aeb3b004644c009c36c5e9b37d429">ring_buffer_remaining_entries</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer);
<a name="l00109"></a>00109 u16 <a class="code" href="ring__buffer_8h.html#a06915ba5348d7cbe361c0bf91bbf7f83">ring_buffer_flush</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer);
<a name="l00110"></a>00110 
<a name="l00111"></a>00111 u16 <a class="code" href="ring__buffer_8h.html#aa9ed8b133ea377b573c3bcbc1127cc0e">ring_buffer_write</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u8 *entry, u32 num_bytes);
<a name="l00112"></a>00112 u16 <a class="code" href="ring__buffer_8h.html#aa3b83c01c65e07ac8f4e382d186cb8e9">ring_buffer_write_multi</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u8 *entry_buff, u32 num_entries, u32 *num_written);
<a name="l00113"></a>00113 
<a name="l00114"></a>00114 u16 <a class="code" href="ring__buffer_8h.html#a2a784b9ebbd7849d654c0866e23b1f97">ring_buffer_read</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u8 *entry, u32 max_bytes);
<a name="l00115"></a>00115 u16 <a class="code" href="ring__buffer_8h.html#a78adbb9324120824e4f75342de380af5">ring_buffer_read_multi</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u8 *entry_buff, u32 entry_buff_size, u32 num_requested, u32 *num_read);
<a name="l00116"></a>00116 
<a name="l00117"></a>00117 u16 <a class="code" href="ring__buffer_8h.html#aee8d66bd666f01d63ae5849310abe028">ring_buffer_lookahead_read</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u32 offset, u8 *entry, u32 max_bytes);
<a name="l00118"></a>00118 u16 <a class="code" href="ring__buffer_8h.html#a90220a5df5993d1f0ac42c06f18915cb">ring_buffer_lookahead_read_multi</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u32 offset, u8 *entry_buff, u32 entry_buff_size, u32 num_requested, u32 *num_read);
<a name="l00119"></a>00119 
<a name="l00120"></a>00120 u32 <a class="code" href="ring__buffer_8h.html#a5a945b91fc139a119cb5b905bf6a9182">ring_buffer_copy</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *to, <a class="code" href="struct__ring__buffer.html">ring_buffer</a> *from, u32 num_entries);
<a name="l00121"></a>00121 u32 <a class="code" href="ring__buffer_8h.html#ac7560884e3e86419dd3e5dde1bd91827">ring_buffer_lookahead_copy</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *to, u32 offset, <a class="code" href="struct__ring__buffer.html">ring_buffer</a> *from, u32 num_entries);
<a name="l00122"></a>00122 u16 <a class="code" href="ring__buffer_8h.html#a35acc1e6935693533294bf4be7b8e30c">ring_buffer_consume_entries</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer, u32 num_entries);
<a name="l00123"></a>00123 
<a name="l00124"></a>00124 u8 *<a class="code" href="ring__buffer_8h.html#ae4a8700d5d233011f02bf2eb108f3feb">ring_buffer_get_first_element_ptr</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer); 
<a name="l00125"></a>00125 u16 <a class="code" href="ring__buffer_8h.html#a2aec6501ce2528ff75aa9505e9218f7c">ring_buffer_remove_first_element</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer); 
<a name="l00126"></a>00126 
<a name="l00127"></a>00127 u8 *<a class="code" href="ring__buffer_8h.html#af6e1b39fe5f3c6099280ea7c92ae8432">ring_buffer_get_available_element_ptr</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer); 
<a name="l00128"></a>00128 u16 <a class="code" href="ring__buffer_8h.html#a69bb8f0b107955c2c853a5725bdb47b5">ring_buffer_increment_count</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer); 
<a name="l00129"></a>00129 
<a name="l00130"></a>00130 u16 <a class="code" href="ring__buffer_8h.html#a7151050a066e68ad75008b596b4cd6bf">ring_buffer_malloc_free</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer);
<a name="l00131"></a>00131 
<a name="l00132"></a>00132 <span class="comment">//Internal</span>
<a name="l00133"></a>00133 
<a name="l00134"></a>00134 <span class="keywordtype">void</span> <a class="code" href="ring__buffer_8h.html#aecc675caf52402d74ffeb7aaaade795d">__ring_buffer_reset</a>(<a class="code" href="struct__ring__buffer.html">ring_buffer</a> *buffer);
<a name="l00135"></a>00135 
<a name="l00136"></a>00136 
<a name="l00137"></a>00137 <span class="preprocessor">#ifdef __cplusplus</span>
<a name="l00138"></a>00138 <span class="preprocessor"></span>}
<a name="l00139"></a>00139 <span class="preprocessor">#endif</span>
<a name="l00140"></a>00140 <span class="preprocessor"></span>
<a name="l00141"></a>00141 <span class="preprocessor">#endif</span>
</pre></div></div>
</div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Defines</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>



<hr class="footer"/><address class="footer"><small>
Generated on Fri May 30 2014 17:03:33 for C MIP-SDK by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.7.5.1
</small></address>

</body>
</html>
